package com.oocl.action.impl;

import java.io.File;
import java.io.FileInputStream;
import java.util.Comparator;
import java.util.List;

import com.oocl.action.ProcessAction;
import com.oocl.pojo.Customer;
import com.oocl.processor.FileProcessor;
import com.oocl.processor.impl.FileProcessorImpl;
import com.oocl.scanner.impl.ScannerImpl;

/**
 * 文件处理过程
 * @author GANAB
 *
 */
public class FileProcessAction extends ProcessAction<Boolean>{
	private FileProcessor fp = null;


	public FileProcessAction(Comparator<Customer> comparator, String format) {
		this.setComparator(comparator);
		this.setFormat(format);
	}
	
	public Boolean action() throws Exception {
		//加载数据
		this.setScanner(new ScannerImpl(new FileInputStream("data.txt")));
		List<Customer> list = this.getScanner().scan();
		//处理
		fp = new FileProcessorImpl(list, this.getFormat());
		return fp.process(this.getComparator(), new File("dataPrint."+this.getFormat()));
	}

}
